﻿using AutoMapper;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace Hx.ADSyncPlatform.AutoMapper
{
    public static class AutoMapperSetup
    {
        public static void AddAutoMapperSetup(this IServiceCollection services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));

            services.AddAutoMapper(n =>
             {
                 n.ForAllMaps((a, b) => b.ForAllMembers(opt => opt.Condition((src, dest, sourceMember) => sourceMember != null)));
                 n.AddProfile(new CustomProfile());
             }
          );

        }
    }
}
